package huffmanCode;

/**
 * @program: data_structures_algorithms
 * @description: 哈夫曼编码
 * @author: lld
 * @create: 2020-11-06 17:40
 */
public class HuffmanCode {
    public static void main(String[] args) {
        int a='a';
        byte b='a';
        System.out.println(a);
        System.out.println(b);
    }
}
class Node implements Comparable<Node> {
    Byte data;//字符对应的字节码
    int wight;//字符出现次数作为权值
    Node left;
    Node right;

    public Node(Byte data, int wight) {
        this.data = data;
        this.wight = wight;
    }

    public Node(Byte data, int wight, Node left, Node right) {
        this.data = data;
        this.wight = wight;
        this.left = left;
        this.right = right;
    }

    @Override
    public String toString() {
        return "Node{" +
                "data=" + data +
                ", wight=" + wight +
                '}';
    }

    @Override
    public int compareTo(Node o) {
        //从小到大排序
        return this.wight - o.wight;
    }

    //输出前序遍历
    public void perOrder() {
        System.out.println(this);
        if (this.left != null) {
            this.left.perOrder();
        }
        if (this.right != null) {
            this.right.perOrder();
        }
    }
}

